package com.example.myapplication.databinding.bindadapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.BindingMethods;
import androidx.databinding.InverseBindingAdapter;
import androidx.databinding.InverseBindingListener;

/**
 * Created by xiaolong on 2022/1/4 6:37 下午
 * email：xinxiaolong123@foxmail.com
 */
public class TextViewBindingAdapter {

    @BindingAdapter({"app:textcontent"})
    public static void setText(View view, String content) {

        if (TextUtils.isEmpty(content)) {
            return;
        }
        if (view instanceof TextView) {
            ((TextView) view).setText(content);
        }
    }

    @BindingAdapter("app:textcontentAttrChanged")
    public static void setTextContentChange(View view, InverseBindingListener textAttrChanged) {

    }

    @InverseBindingAdapter(attribute ="app:textcontent" ,event = "textcontentAttrChanged")
    public static String getTextContent(View view) {
        return "";
    }

}
